var thisObject,allxml;
var object;
var vehicleSingle;
var curTabIndex = 0;
var preTabIndex = 0;
var allInfoPage;
var vehicleInfoPage;
var contactInfoPage;
var commentInfoPage;
var locationInfoPage;
var priceInfoPage;

var DashboardPageMediator = Objs("view.DashboardPageMediator",
	Mediator,
{

	initialize: function( name, viewComponent )
	{   
		DashboardPageMediator.$super.initialize.call( this, name, viewComponent );
    	        this.vProxy = this.facade.retrieveProxy( ProxyNames.VEHICLE_PROXY );
    	        this.assetProxy = this.facade.retrieveProxy( ProxyNames.INITIAL_PROXY );
				
		//this.loginProxy = this.facade.retrieveProxy( ProxyNames.LOGIN_PROXY );
		this.registerListeners();
                vehicleSingle = new VehicleVO();
		thisObject = this;
             
               
              
                
	},
	
	registerListeners: function()
	{   
		var dashboardPage = this.get();	
		dashboardPage.addEventListener( DashboardPage.ALL_REMINDERS, this.getAllReminders, this );
		
		//detailPage.addEventListener(DetailPage.MAKE_CHANGE , this.makechange, this );
	},
        
        get: function()
	{
		return this.viewComponent;
	},
        
        listNotificationInterests: function()
	{
		return [NotificationNames.REMBACK];
        },
        
        handleNotification: function( note )
	{ 
		
		switch ( note.getName() )
		{ 
			case NotificationNames.REMBACK: 
				this.listReminders( note.getBody());
                                
				break;
			
		}
	},
        
        getAllReminders: function()
        {
            this.vProxy.getReminder();
        },
        
        listReminders: function(reminderdata)
        {
           var status='';  
           $("#reminderlistmodel").html('');
            var reminderListHTML="<table id='vehlist-table' class='table table-outer-bordered table-striped' style=font-size:12px;><tbody>";
            
            for(var i=0; i<reminderdata.length; i++)
            {
              if(reminderdata[i].due==1) status="<span class='label label-important'>Due</span>"; else if(reminderdata[i].duesoon==1) status="<span class='label label-warning'>Due Soon</span>"; else status ='';
              
              reminderListHTML+="<tr><td><a href='javascript:void();'>" + reminderdata[i].year + " " + reminderdata[i].make + " " + reminderdata[i].model + "</a><div class='muted'><small>#" +reminderdata[i].vehicleid+ "</small></td><td width='100px'>"+reminderdata[i].setby+"</td><td width='100px'>"+reminderdata[i].setdate+"</td><td width='100px'>"+reminderdata[i].todate+"</td><td>"+ status+"</td><td>"+ reminderdata[i].remindnote+"</td><td width='40px;'><div class='btn-group'><a class='btn btn-mini dropdown-toggle' data-toggle='dropdown' href='javascript:void();'><i class='icon-cog'></i><span class='caret'></span></a><ul class='dropdown-menu pull-right'><li><a href='#editItemPopup' role='button' data-toggle='modal' onClick='thisadminpage.onEditAdsource("+i+");'><i class='icon-pencil'></i>&nbsp;&nbsp;Edit Reminder</a></li><li><a href='javascript:void();' onClick='thisadminpage.onDeleteAdsource("+i+");'><i class=' icon-trash'></i>&nbsp;&nbsp;Delete Reminder</a></li></ul></div></td></tr>"
             
              
            }
          
              reminderListHTML+="</tbody></table>";
              $("#reminderlistmodel").html(reminderListHTML);
        }
	
	
	
	
});

